package com.itheima.health.dao;

import com.itheima.health.pojo.entity.Menu;
import com.itheima.health.pojo.entity.Permission;
import com.itheima.health.pojo.entity.Role;
import com.itheima.health.pojo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
 * @author ：zhang
 * @date ：Created in 2019/11/20
 * @description ：用户DAO
 * @version: 1.0
 */
@Mapper
public interface UserDao {

    /**
     * 根据userName查询
     * @param username
     * @return
     */
    User selectByUsername(@Param("username") String username);

    @Insert("insert into t_user(birthday, gender, username, password, remark, station, telephone) VALUES " +
            "(#{birthday},#{gender},#{username},#{password},#{remark},#{station},#{telephone})")
    void add(User user);

    //获取role
    Set<Role> getRoles(@Param("userId")Long userId);

    //获取role关联的permission
    Set<Permission> getPermission(@Param("roleId")Integer roleId);

    //获取role关联的menu菜单
    LinkedHashSet<Menu> getMenus(@Param("roleId")Integer roleId);

    List<Menu> getChild(@Param("roleId")Integer id);
}
